package com.dmall.chapter10.section03;

import com.dmall.chapter02.section09.Graph;
import com.dmall.chapter04.section02.CC;

public class EulerLoop {

    private Graph G;

    public EulerLoop(Graph G) {
        this.G = G;
    }

    public boolean hasEulerLoop() {
        CC cc = new CC(this.G);
        if (cc.count() > 1) {
            return false;
        }
        for (int v = 0; v < G.V(); v++) {
            if (G.degree(v) % 2 == 1) {
                return false;
            }
        }
        return true;
    }
}
